<?php
/**
* Simple example script using PHPMailer with exceptions enabled
* @package phpmailer
* @version $Id$
* 验证注册邮箱 2011-12
*/

require '../class.phpmailer.php';

try {
	$mail = new PHPMailer(true); //New instance, with exceptions enabled

	//$mail->CharSet = "utf8";

	$body             = file_get_contents('contents.html');
	$body             = preg_replace('/\\\\/','', $body); //Strip backslashes
	
	$username = isset($_GET['username']) ? trim($_GET['username']) : '测试用户';
	$url	  = isset($_GET['url']) ? trim($_GET['url']) : 'http://thinkphp_projects.me';
	$datetime = date("Y-m-d H:i:s");
	
	$body			  = str_replace( array('$username', '$url', '$datetime'), array($username, $url, $datetime), $body );
	

	$mail->IsSMTP();                           // tell the class to use SMTP
	$mail->SMTPAuth   = true;                  // enable SMTP authentication
	$mail->Port       = 25;                    // set the SMTP server port
	$mail->Host       = "smtp.qq.com"; // SMTP server
	$mail->Username   = "admin@haaway.com";     // SMTP server username
	$mail->Password   = "admin";            // SMTP server password

	//$mail->IsSendmail();  // tell the class to use Sendmail

	//$mail->AddReplyTo("name@domain.com","First Last");

	$mail->From       = "admin@haaway.com";
	$mail->FromName   = "家教网";

	$to = "cxmcook@163.com";

	$mail->AddAddress($to);

	$mail->Subject  = "家教网注册邮箱验证";

	$mail->AltBody    = "本消息如果不能正确读取，请换一个支持HTML的浏览器"; // optional, comment out and test
	$mail->WordWrap   = 80; // set word wrap

	$mail->MsgHTML($body);

	$mail->IsHTML(true); // send as HTML

	$mail->Send();
	echo '邮件成功发送';
} catch (phpmailerException $e) {
	echo $e->errorMessage();
}
?>